package com.dog.demo.controller;


import com.dog.demo.pojo.Smbms;
import com.dog.demo.service.userService;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {
    @Resource
    private userService userService;
    @GetMapping("/userList")
    public Object userList(){
        return userService.getSmbms();
    }
    @GetMapping("/alist")
    public ModelAndView list(){
        return new ModelAndView("list");
    }
    @GetMapping("/age")
    public ModelAndView ose() {
        return new ModelAndView("add");
    }
    @GetMapping("/upse")
    public ModelAndView ups(Model model,int id) {
        List<Smbms> sm=userService.getlist(id);
        model.addAttribute("sm",sm);
        return new ModelAndView("ups");
    }
    @GetMapping("/ins")
    public ModelAndView ins(Smbms smbms){
int i=userService.getins(smbms);
if (i>0){
    return new ModelAndView("list");

}else {
    return new ModelAndView("add");
}
    }
    @GetMapping("/dele")
    public ModelAndView dele(int id) {
        int ids=userService.deles(id);
        return new ModelAndView("list");
    }
}
